<?
//购物车
function setgoodscart($proid,$buynum){
	$goodcartstr=$_COOKIE['sys_goodscart'];
	$goodcartstr1='';
	if ($goodcartstr){
		$goodscartary=explode('|',$goodcartstr);
		$qz=0;
		foreach($goodscartary as $k1=>$v1){
			$goodscartary1=explode(',',$v1);
			if($proid==$goodscartary1[0]){
				$qz=1;
				if ($goodcartstr1) $goodcartstr1.='|';$goodcartstr1.=$goodscartary1[0].','.($goodscartary1[1]+$buynum);
			}else{
				if ($goodcartstr1) $goodcartstr1.='|';$goodcartstr1.=$goodscartary1[0].','.$goodscartary1[1];
			}
		}
		if($qz==0){
			if ($goodcartstr1) $goodcartstr1.='|';$goodcartstr1.=$proid.','.$buynum;
		}
	}else{
		$goodcartstr1.=$proid.','.$buynum;
	}
	
	setcookie("sys_goodscart",$goodcartstr1);
	return true;
}

function editgoodscart($proid,$buynum){
	$goodcartstr=$_COOKIE['sys_goodscart'];
	$goodcartstr1='';
	if ($goodcartstr){
		$goodscartary=explode('|',$goodcartstr);
		foreach($goodscartary as $k1=>$v1){
			$goodscartary1=explode(',',$v1);
			if($proid==$goodscartary1[0]){
				if ($buynum>0){
					if ($goodcartstr1) $goodcartstr1.='|';$goodcartstr1.=$goodscartary1[0].','.$buynum;
				}
			}else{
				if ($goodcartstr1) $goodcartstr1.='|';$goodcartstr1.=$goodscartary1[0].','.$goodscartary1[1];
			}
		}
	}else{
		$goodcartstr1.=$proid.','.$buynum;
	}
	setcookie("sys_goodscart",$goodcartstr1);
	return true;
}
?>